<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
	<ui:composition template="/template.xhtml">
		<ui:define name="content">
			<h:form id="formQuanLy">
				<p:panel styleClass="layout_2_L" id="pn_left">
				<p:accordionPanel>
					<p:ajax event="tabChange" listener="#{quanLyBean.onTabChange}"
							update=":formQuanLy:tblLichDk" />
						<p:tab id="tab1" title="Xem theo tuần">
							<p:calendar value="#{quanLyBean.date}" mode="inline">
								<p:ajax event="dateSelect"
									listener="#{quanLyBean.handleDateSelect}" update=":formQuanLy:tblLichDk" />
							</p:calendar>
							<p:commandButton actionListener="#{quanLyBean.hienThiDangKyTrungTheoTuan}" update=":formQuanLy:tblLichDk" value="Hiển thị đăng ký trùng" icon="ui-icon-note"/>
						</p:tab>
						<p:tab id="tab2" title="Xem theo ngày">
							<p:calendar value="#{quanLyBean.date1}" mode="inline">
								<p:ajax event="dateSelect"
									listener="#{quanLyBean.handleDate1Select}" update=":formQuanLy:tblLichDk" />
							</p:calendar>
							<p:commandButton actionListener="#{quanLyBean.hienThiDangKyTrungTheoNgay}" update=":formQuanLy:tblLichDk" value="Hiển thị đăng ký trùng" icon="ui-icon-note"/>
						</p:tab>
				</p:accordionPanel>
				</p:panel>
				<p:panel styleClass="layout_2_R" id="pn_right">
					<p:dataTable id="tblLichDk" var="lichDk"
						value="#{quanLyBean.lichDangKyList}" rowIndexVar="rowIndex">
						<f:facet name="header">
							<h:outputText value=" Thông tin đăng ký phòng máy " />
							<h:outputText id="ngayHienThi" value="#{quanLyBean.ngayHienThi}"
								styleClass="blue">
								<f:convertDateTime pattern="dd/MM/yyyy" />
							</h:outputText>
						</f:facet>
						<p:column headerText="STT" styleClass="textCenter">
							<h:outputText value="#{rowIndex+1}" />
						</p:column>
						<p:column headerText="Phòng" styleClass="textCenter">
							<h:outputText value="#{lichDk.tenPhongMay}" />
						</p:column>
						<p:column headerText="Tiết" styleClass="textCenter">
							<h:outputText value="#{lichDk.moTaTietHoc}" />
						</p:column>
						<p:column headerText="Ngày" styleClass="textCenter">
							<h:outputText value="#{lichDk.ngayDat}">
								<f:convertDateTime pattern="dd/MM/yyyy" />
							</h:outputText>
						</p:column>
						<p:column headerText="Giáo viên">
							<h:outputText value="#{lichDk.tenGiaoVien}" />
						</p:column>
						<p:column headerText="Tiêu đề">
							<h:outputText value="#{lichDk.tieuDe}" />
						</p:column>
						<p:column headerText="Mô tả">
							<h:outputText value="#{lichDk.moTa}" />
						</p:column>
						<p:column headerText="Yêu cầu">
							<h:outputText value="#{lichDk.yeuCau}" />
						</p:column>
						<p:column headerText="Trạng thái" styleClass="textCenter">
							<h:outputText
								value="#{lichDangKyBean.convertStatus(lichDk.status)}" />
						</p:column>
						<p:column headerText="Đồng ý" styleClass="textCenter">
							<p:commandButton actionListener="#{quanLyBean.dongY(lichDk.id)}"
								update="tblLichDk" icon="ui-icon-check" 
								disabled="#{quanLyBean.disabledDongY(lichDk.status)}"/>
						</p:column>
						<p:column headerText="Từ chối" styleClass="textCenter">
							<p:commandButton
								actionListener="#{quanLyBean.setIdHuy(lichDk.id)}"
								update="tblLichDk" onclick="dlg.show()" icon="ui-icon-trash" 
								disabled="#{quanLyBean.disabledTuChoi(lichDk.status)}"/>
						</p:column>
					</p:dataTable>
				</p:panel>
				<p:dialog widgetVar="dlg">
					<h:panelGrid>
						<f:facet name="header">
							<p:row>
								<p:column colspan="2">Lý do hủy đăng ký</p:column>
							</p:row>
						</f:facet>
						<p:row>
							<p:column colspan="2">
								<p:inputTextarea value="#{quanLyBean.lyDo}" />
							</p:column>
						</p:row>
						<p:row>
							<p:column>
								<p:commandButton value="Hoàn thành"
									actionListener="#{quanLyBean.tuChoi}" update=":formQuanLy"
									onclick="dlg.close()" />
							</p:column>
							<p:column>
								<p:commandButton value="Hủy" onclick="dlg.hide()" />
							</p:column>
						</p:row>
					</h:panelGrid>
				</p:dialog>
			</h:form>
		</ui:define>
	</ui:composition>
</h:body>
</html>